package com.qf.blog.controller;

import com.qf.blog.entity.DiscussPost;
import com.qf.blog.entity.User;
import com.qf.blog.service.IDiscussPostService;
import com.qf.blog.vo.PostVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
@Controller
public class IndexController {
    @Autowired
    private IDiscussPostService postService;
    @RequestMapping("/")
    public String index(Model model,Integer orderMode){

        List<PostVo> postVos = postService.getPostVoList(orderMode);
        System.out.println("postVos = " + postVos);
        model.addAttribute("postVos",postVos);
        return "index";
    }

    @RequestMapping("/{path}/{page}.html")
    public String toPage(@PathVariable("path") String path,@PathVariable("page") String page){
        System.out.println("path = " +path);
        System.out.println("path = " + path+",page = " + page);
        return path+"/"+page;
    }

}
